

import java.awt.BorderLayout;
/**
 * A Baseball game program.
 * 
 * written by Gihoon Kim.
 * 
 * 
 */

import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;


public class BaseballGame extends JFrame implements ActionListener{

	//game window
	protected JTextArea  _messageArea= new JTextArea(10, 32);
	private JTextField  _textField= new JTextField(32);
	
	public BaseballGame(String namespace) {
		
		addWindowListener(
		           new WindowAdapter() {
		               public void windowClosing(WindowEvent e) {
		                   try {
							stop();
						} catch (IOException e1) {
							System.out.println("IOException shutting down listener: " + e1);
							e1.printStackTrace();
						}
		               }
		           }
	    );
		
		//make window
		_messageArea.setEditable(false);
		_messageArea.setBackground(Color.LIGHT_GRAY);
		_messageArea.setLineWrap(true);
		_textField.addActionListener(this);
		
		Container content = getContentPane();
		content.add(new JScrollPane(_messageArea), BorderLayout.CENTER);
		content.add(_textField, BorderLayout.SOUTH);
		
		//display the window
		setTitle("Baseball game: ["+namespace+"]");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		pack();
		_textField.requestFocusInWindow();
		setVisible(true);
	}
	
	/**
	 * Process input to textfield.
	 */
	public void actionPerformed(ActionEvent e) {
		try{
			String newText = _textField.getText();
			if((null != newText) && (newText.length() >0)){
				
			}
		}
		catch(Exception e1){
			
		}
		
	}
	
	/**
	 * Called by window thread when window is closed.
	 */
	protected void stop() throws IOException{
	////////////////////////////////////////////////////////////////////////////////////
	}
	
}
